<?php

class myUser extends sfGuardSecurityUser {

    public function getId() {
        return $this->getAttribute('user_id', null, 'sfGuardSecurityUser');
    }

    public function getTypeUser() {
        $user = sfGuardUserTable::getInstance()->find($this->getId());
        return $user['type'];
    }

    public function getNom() {
        $user = sfGuardUserTable::getInstance()->find($this->getId());
        return $user['first_name'];
    }
    public function setDate($date){
        $user = sfGuardUserTable::getInstance()->find($this->getId());
        $user->setDate($date);
        $user->save();
    }
    public function getDepartementId() {
        return $this->getGuardUser()->getDepartementId();
    }
    public function getName(){
        return $this->getGuardUser()->getName();
    }
    public function haveAdminPermission(){
        $currentPermissions = sfGuardUserPermissionTable::getInstance()->findByUserId($this->getGuardUser()->getId());
        foreach ($currentPermissions as $usr_permission) {
            if($usr_permission->getPermission()->getName()=='PermissionAdmin')
                return true;
        }
        return false;
        
    }
}